

package com.caltco.cargo.ops.common.api;



/**
 * 返回数据
 *
 * @author
 * @email
 * @date 2016年10月27日 下午9:59:27
 */
public class R{
    private static final long serialVersionUID = 1L;


    private Integer code;

    private String type;

    private String message;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public R() {
        this.code = 200;
        this.type = "success"; //'success' | 'error' | 'warning'
        this.message = "ok";
    }

    public static R error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static R error(String msg) {
        return error(500, msg);
    }

    public static R error(int code, String msg) {
        R r = new R();
        r.setCode(code);
        r.setMessage(msg);
        r.setType("error");
        return r;
    }

    public static R ok(String msg) {
        R r = new R();
        r.setMessage(msg);
        return r;
    }

    public static R ok() {
        return new R();
    }
}
